package com.spzx.user.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.user.api.RemoteUserInfoService;
import com.spzx.user.api.domain.UpdateUserLogin;
import com.spzx.user.api.domain.UserAddress;
import com.spzx.user.api.domain.UserInfo;
import org.springframework.cloud.openfeign.FallbackFactory;

//@Component
public class RemoteUserInfoFallbackFactory  implements FallbackFactory<RemoteUserInfoService>{

    @Override
    public RemoteUserInfoService create(Throwable cause) {

        return new RemoteUserInfoService(){
            @Override
            public void register(UserInfo userInfo, String inner) {
                System.out.println("register error");
            }

            @Override
            public R<UserInfo> getUserInfo(String username, String inner) {
                System.out.println("getUserInfo error");
                return R.fail(cause.getMessage());
            }

            @Override
            public R<Boolean> updateUserLogin(UpdateUserLogin updateUserLogin, String inner) {
                System.out.println("updateUserLogin error");
                return R.fail(cause.getMessage());
            }

            @Override
            public R<UserAddress> getUserAddress(Long id, String source) {
                System.out.println("getUserAddress error");
                return R.fail(cause.getMessage());
            }


        };
    }
}
